function x = SK6_Acceleration_Read_Demo( COM_PORT );
% Demonstrate and display the SK7's acceleration outputs.
%
% COM_PORT is a string contianing the COM port name that the SK6 is
% connectable on.
%
% Example Usage: SK6_Acceleration_Read_Demo( 'COM2' )

% Start the connection and configure the SK6
SK6_Start( 'open' , COM_PORT );

% read the sensor ID structure
IDs = SK6_Get_Sensor_IDs();

fprintf( 1 , 'Press the navigation switch on the SK6 to exit....\n' );

% main loop - keep getting new attitude data and call the display function
while(1)

	% wait until there is at least one packet
  while ((SK6_Data_Samples_Available( IDs.Accelerometer ) == 0) || (SK6_Data_Samples_Available( IDs.Gyro ) == 0) )
    pause( 0.002 ); % prevent busy waiting
  end
  
  % read a packet
  acc = SK6_Get_Sensor_Data( IDs.Accelerometer , 1 )
  gyr = SK6_Get_Sensor_Data( IDs.Gyro , 1 )
  
  % display the packet
	fprintf( 1 ,'Acceleration: X = %04.1d , Y = %04.1d , Z = %04.1d \n', acc( 1 ),acc( 2 ),acc( 3 ) );
	fprintf( 1 ,'Rotation: Roll = %04.1d , Pitch = %04.1d , Yaw = %04.1d \n', gyr( 2 ),gyr( 1 ),gyr( 3 ) );
	% check if there is a press of the navigation switch and break if there is
	if( SK6_Data_Samples_Available( IDs.NavSwitch ) > 0 ) 
	break
	end  

end

% close the serial port connection
SK6_Start( 'close' , '' );

end % end of function
